// 年级\班级表
const sequelize = require( '../config.js')
const { DataTypes } = require('sequelize')
const grade = sequelize.define('grade', {
  Id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    comment: '年级ID',
  },

  grade_name: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '年级名称',
  },
  grade_level: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '年级级别',
  },
  grade_school_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: 'school_infos',
      key: 'school_id',
    },
    onDelete: 'CASCADE',
    comment: '年级所属院校ID',
  },
  },{ timestamps: false});
  const gradeClass = sequelize.define('gradeClass', {
    class_id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
      comment: '班级ID',
    },
    grade_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'grades',
        key: 'Id',
      },
      onDelete: 'CASCADE',
      comment: '所属年级ID',
    },
    class_name: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: '班级名称',
    }
    },{ timestamps: false});
module.exports = {grade,gradeClass};